import 'package:flutter/material.dart';
import 'package:jd_flutter/base/pre_init/pre_init.dart';
import 'package:jd_flutter/base/widget/image/jd_network_image.dart';
import 'package:jd_flutter/base/widget/ui/text_image_button.dart';
import 'package:jd_flutter/modules/router/router_contract_page.dart';

class HomeHeaderWidget extends StatelessWidget {
  const HomeHeaderWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
          padding: const EdgeInsets.fromLTRB(15, 0, 15, 17),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              getEnterWidget('flutter'),
              getEnterWidget('编程'),
              getEnterWidget('学习'),
              getEnterWidget('高手'),
              getEnterWidget('拿到offer'),
            ],
          ),
        )
      ],
    );
  }

  getEnterWidget(String name) {
    return TextImageButton(
      minWidth: 48,
      height: 38 + 17,
      onPressed: () {
        RouterContractPage.instance.webViewPage.push(PreInit.currentContext,
            params: {"title": name, "url": 'https://www.baidu.com'});
      },
      alignment: IconTextAlignment.iconTopTextBottom,
      imageWidget: JDNetworkImage(
        url: getRandomImageUrl(),
        width: 34,
        height: 34,
        borderRadius: const BorderRadius.all(Radius.circular(3)),
      ),
      text: Text(
        name,
        style: const TextStyle(color: Color(0xFF525252), fontSize: 12),
      ),
    );
  }
}
